package com.example.java_dao;

import com.example.java_pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.context.annotation.ComponentScan;

import java.util.List;

@Mapper
@ComponentScan("com.example.java_pojo")
public interface UserDao {
    @Select("select * from user where id=#{id}")
    User findById(Integer id);

    @Select("select * from user")
    List<User> findAll();
    @Select("select * from user where username=#{name}")
    User findByName(String name);

    @Insert("insert into user(username,password) values(#{username},#{password})")
    void save(User user);

    @Update("update user set username=#{username},password=#{password} where id=#{id}")
    void update(User user);

    @Delete("delete from user where id=#{id}")
    void delete(Integer id);

    @Select("select * from user where username=#{username} and password=#{password}")
    User select(String username,String password);
}
